<?php

/**
 * Description of LoanStatus
 *
 * @author andres
 */
class Emms_LoanStatus 
{
    private $_status;
    private $_action;
    
    public function __construct($status) 
    {
        $this->_action = array();
        
        $this->_action['New'] = array();
        $this->_action['New']['VIEW'] = true;
        $this->_action['New']['SUBMIT'] = true;
        $this->_action['New']['EDIT'] = true;
        $this->_action['New']['DELETE'] = true;
        $this->_action['New']['CHANGEDATES'] = true;
        
        $this->_action['Submitted'] = array();
        $this->_action['Submitted']['REVIEW'] = true;
        $this->_action['Submitted']['REJECT'] = true;
        $this->_action['Submitted']['WITHDRAW'] = true;
        $this->_action['Submitted']['CHANGEDATES'] = true;
        
        $this->_action['Reviewed'] = array();
        $this->_action['Reviewed']['APPROVE'] = true;
        $this->_action['Reviewed']['REJECT'] = true;
        $this->_action['Reviewed']['WITHDRAW'] = true;
        $this->_action['Reviewed']['CHANGEDATES'] = true;
        
        $this->_action['Approved'] = array();
        $this->_action['Approved']['EXECUTE'] = true;
        $this->_action['Approved']['WITHDRAW'] = true;
        $this->_action['Approved']['CHANGEDATES'] = true;
        
        $this->_action['Executed'] = array();
        $this->_action['Executed']['DISBURSE'] = true;
        $this->_action['Executed']['WITHDRAW'] = true;
        $this->_action['Executed']['CHANGEDATES'] = true;
        
        $this->_action['Disbursed'] = array();
        //$this->_action['Disbursed']['VIEW'] = true;
        
        $this->_action['Withdrawn'] = array();
        
        $this->_action['Rejected'] = array();
        $this->_action['Rejected']['VIEW'] = true;
        $this->_action['Rejected']['SUBMIT'] = true;
        $this->_action['Rejected']['RESUBMIT'] = true;
        $this->_action['Rejected']['EDIT'] = true;
        $this->_action['Rejected']['DELETE'] = true;
        $this->_action['Rejected']['WITHDRAW'] = true;
        $this->_action['Rejected']['CHANGEDATES'] = true;
        
        if(is_array($this->_action[$status])) {
            $this->_status = $status;
        } else {
            throw new Exception('Invalid request');
        }
    }
    
    public function isViewOkay()
    {
        return isset($this->_action[$this->_status]['VIEW']) ? true : false;
    }
    
    public function isSubmitOkay()
    {
        return isset($this->_action[$this->_status]['SUBMIT']) ? true : false;
    }
    
    public function isReSubmitOkay()
    {
        return isset($this->_action[$this->_status]['RESUBMIT']) ? true : false;
    }
    
    public function isEditOkay()
    {
        return isset($this->_action[$this->_status]['EDIT']) ? true : false;
    }
    
    public function isChangeDatesOkay()
    {
        return isset($this->_action[$this->_status]['CHANGEDATES']) ? true : false;
    }
    
    public function isDeleteOkay()
    {
        return isset($this->_action[$this->_status]['DELETE']) ? true : false;
    }
    
    public function isReviewOkay()
    {
        return isset($this->_action[$this->_status]['REVIEW']) ? true : false;
    }
    
    public function isApproveOkay()
    {
        return isset($this->_action[$this->_status]['APPROVE']) ? true : false;
    }
    
    public function isExecuteOkay()
    {
        return isset($this->_action[$this->_status]['EXECUTE']) ? true : false;
    }
    
    public function isDisburseOkay()
    {
        return isset($this->_action[$this->_status]['DISBURSE']) ? true : false;
    }
    
    public function isWithdrawOkay()
    {
        return isset($this->_action[$this->_status]['WITHDRAW']) ? true : false;
    }
    
    public function isRejectOkay()
    {
        return isset($this->_action[$this->_status]['REJECT']) ? true : false;
    }
}

?>
